package io.yx.flx.test;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.simple.SimpleDataSource;
import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

/**
 * MySQL数据转移到sqlite
 * 使用此类需要引入mysql驱动包
 */
public class TransferData {

    private static final Log log = LogFactory.get();

    public static void main(String[] args) throws SQLException {

        DataSource ds = new SimpleDataSource("jdbc:mysql://localhost:3306/fileserver", "root", "root");

        List<Entity> fileInfos = Db.use(ds).find(Entity.create("file_info"));
        for (Entity entity : fileInfos) {
            Db.use().insert(entity);
        }

    }


}
